package com.xiaomi.shwx.common.config;

import com.xiaomi.shwx.interceptor.JwtTokenInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;

/**
 * @author lei
 * @description 拦截器配置 为方便测试，先不开启
 */
@Configuration
public class MyWebMvcConfig implements WebMvcConfigurer {
    private static List<String> excludePathList= Arrays.asList("/api/user/login", "/api/user/register");

    @Resource
    private JwtTokenInterceptor jwtTokenInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
//        registry.addInterceptor(jwtTokenInterceptor)
//                // 添加拦截器，指定拦截的路径为/api/**，
//                .addPathPatterns("/api/**")
//                // excludePathPatterns方法用来设置不需要拦截的路径，比如登录或注册接口
//                .excludePathPatterns(excludePathList);
    }

}
